package com.moji.controller.api;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjAboutUs;
import com.moji.entity.MjOrder;
import com.moji.entity.dto.AddOrderDto;
import com.moji.entity.dto.QueryOrderDto;
import com.moji.entity.vo.OrderVo;
import com.moji.service.MjOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-07-27
 */
@RestController
@RequestMapping("/api/mjOrder")
@Api(tags = "订单管理api相关接口", value = "订单管理api相关接口")
public class MjOrderController {

    @Resource
    private MjOrderService mjOrderService;

    @PostMapping("/add")
    @ApiOperation(value = "订单_新增",response = Boolean.class)
    public ApiResult add(@Validated @RequestBody AddOrderDto addOrderDto){
        return ApiResult.ok(mjOrderService.add(addOrderDto));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "订单_编辑",response = Boolean.class)
    public ApiResult edit(@Validated @RequestBody AddOrderDto addOrderDto){
        return ApiResult.ok(mjOrderService.edit(addOrderDto));
    }

    @GetMapping("/delete")
    @ApiOperation(value = "订单_删除",response = Boolean.class)
    public ApiResult delete(@RequestParam("id") Long id){
        return ApiResult.ok(mjOrderService.delete(id));
    }

    @PostMapping("/queryByPage")
    @ApiOperation(value = "订单_分页查询",response = MjOrder.class)
    public ApiResult queryByPage(@RequestBody QueryOrderDto dto){
        return ApiResult.ok(mjOrderService.queryByPage(dto));
    }

     @GetMapping("/detail")
    @ApiOperation(value = "订单_详情",response = OrderVo.class)
    public ApiResult detail(@RequestParam("id") Long id){
        return ApiResult.ok(mjOrderService.detail(id));
    }

    @GetMapping("/editAmount")
    @ApiOperation(value = "订单_修改金额",response = Boolean.class)
    public ApiResult detail(@RequestParam("id") Long id,@RequestParam("amount") String amount){
        return ApiResult.ok(mjOrderService.editAmount(id,amount));
    }

// //    @GetMapping("/audit")
// //    @ApiOperation(value = "审核通过",response = Boolean.class)
// //    public ApiResult audit(@RequestParam("id") Long id){
// //        return ApiResult.ok(mjOrderService.audit(id));
// //    }

     @GetMapping("/cancel")
     @ApiOperation(value = "审核取消",response = Boolean.class)
     public ApiResult cancel(@RequestParam("id") Long id){
         return ApiResult.ok(mjOrderService.cancel(id));
     }


     @GetMapping("/shenhe")
     @ApiOperation(value = "审核对公支付订单状态",response = Boolean.class)
     public ApiResult shenhe(@RequestParam("id") Long id){
         return ApiResult.ok(mjOrderService.shenhe(id));
     }

    @GetMapping("/refuse")
    @ApiOperation(value = "审核驳回",response = Boolean.class)
    public ApiResult refuse(@RequestParam("id") Long id){
        return ApiResult.ok(mjOrderService.refuse(id));
    }

}

